// 列表选择
$(document).on('tap', '.list > .mui-table-view + div li', function () {
    var tapText = $(this).children().html();
    var _id = $(this).parents('.mui-popover').attr('id');
    var $show = $('a[href="#' + _id + '"]').children().last();
    if (tapText !== '取消') {
        $show.html(tapText);
    }
    mui('#' + _id).popover('hide');
});


/*$('.toast').on('tap', function () {
 mui.toast("5000以上且需提供银行流水")
 })*/
//将各个列表项转换为数组
function ToArr() {
    this.resParam = [];
}
ToArr.prototype = {
    rechange: function (t, r) { //获取选项框的有效数据
        var arr = [];
        $(t).each(function (i) {
            var arg = $(t).eq(i).text().replace(r, "")
            if (r === undefined) { //price
                arr[i] = parseInt($(t).eq(i).val() * 10000) / 10000; // 直接传 万元 如 0.8
            } else {
                if (arg == '选择' || arg == '') {
                    arr[i] == ''
                } else {
                    arr[i] = parseInt($(t).eq(i).text().replace(r, ""))
                }
            }
        });
        return arr;
        /*$(this.target).each((i)=> {
         thrr[i] = parseInt($(this.target).eq(i).text().replace(this.replace, ""));
         });
         return this.arr;*/ //es6 arrow function
    },
    getStr: function (t) {
        var arr = [];
        $(t).each(function (i) {
            arr[i] = $(t).eq(i).val();
        });
        return arr;
    }, //获取贷款编号
    getType: function (t) { //获取类型
        var arr = [];
        $(t).each(function (i) {
            arr[i] = $(t).html().replace(/\s/g, '');
        });
        return arr;
    },
    append: function (list) { //添加
        $(".add-button").on('tap', function () {
            $('.buttons').before(list)
            addI++;
        })
    },
    getParams: function (obj) { //得到请求参数
        for (var i = 0; i < $('.list').length; i++) {
            this.resParam[i] = {};
            var j;
            for (j in obj) {
                this.resParam[i][j] = obj[j][i];
            }
        }
        return this.resParam;
    },
    getAjax: function (loanCode, resParam) { // 评估接口
        $.ajax({
            url: ur + "rest/loanController/evaluate",
            dataType: "json",
            data: {
                loanCode: loanCode,
                param: JSON.stringify(resParam)
            },
            type: "POST",
            success: function (data) {
                if (data.meta.code === 'S002') {
                    localStorage.rsbd = loanCode;
                    localStorage.loanCode = loanCode//评估跳转申请
                    localStorage.rs = data.data;
                    data.data == 0 ? localStorage.assess = 'fail' : localStorage.assess = 'pass'
                    localStorage.params = JSON.stringify(resParam);
                    href('evaluate.html', 'evaluate');
                } else {
                    mui.toast(data.meta.message);
                }
            }
        });
    }
};
